<?php

namespace app\common;

use \think\facade\Request;
use \app\common\model\InventoryChangeRecord as InventoryChangeRecordModel;

/**
 * 库存变更日志
 */
class InventoryChangeRecord
{
    protected $creator;
    protected $inventory_id;
    protected $business_tabel_name;
    protected $business_table_id;
    protected $business;
    protected $number;
    protected $remark;
    protected $create_time;

    /**
     * 初始化
     */
    public function __construct()
    {
        $this->creator = request()->operator_id ?? request()->user_id;
        $this->create_time = date("Y-m-d H:i:s");
    }

    /**
     *  写入日志
     *  p
     */
    public function writeLog($data)
    {
        $data['creator'] = $this->creator;
        $data['create_time'] = $this->create_time;

        return InventoryChangeRecordModel::create($data);
    }

}
